home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / mus / play / DelfMPEG.lha / DelfMPEG / src / PCM.a56 < prev    next >
Text File  |  2002-10-30  |  4KB  |  213 lines

  1. ;*****************************************************************************
  2. ;
  3. ;    DelfMPEG - MPEG audio player for Delfina DSP
  4. ;    Copyright (C) 1999-2002  Michael Henke
  5. ;
  6. ;    This program is free software; you can redistribute it and/or modify
  7. ;    it under the terms of the GNU General Public License as published by
  8. ;    the Free Software Foundation; either version 2 of the License, or
  9. ;    (at your option) any later version.
  10. ;
  11. ;    This program is distributed in the hope that it will be useful,
  12. ;    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. ;    GNU General Public License for more details.
  15. ;
  16. ;    You should have received a copy of the GNU General Public License
  17. ;    along with this program; if not, write to the Free Software
  18. ;    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  19. ;
  20. ;*****************************************************************************
  21.  
  22.  
  23.  
  24.  
  25. ;Delfina object DSP56K_PCM
  26. ;memory map (for Amiga access)
  27. ;
  28. ; prog
  29. ;   0 .. init (x1=mono, x0=volume, y1=freq, y0=/)
  30. ;  +2 .. mute (x1=/, x0=/, y1=/, y0=/)
  31. ;  +4 .. decode_and_interrupt
  32. ;  +6 .. DelfModule
  33. ;
  34. ; xdata
  35. ;   /
  36. ;
  37. ; ydata
  38. ;   0 .. amybuf (Amiga read)
  39.  
  40.  
  41.  
  42.  
  43. DELFINA_SAMPLES    equ    1152
  44.  
  45.  
  46.     include 'delfequ.inc'
  47.  
  48.     org    p:
  49.  
  50. int_key
  51.  
  52. ;->prog
  53.     jmp    init
  54.  
  55. ;->prog+2
  56.     jmp    mute
  57.  
  58. ;->prog+4
  59.     jmp    decode_and_interrupt
  60.  
  61. ;->prog+6
  62.     jmp    interrupt_only
  63.  
  64. ;->prog+8
  65.  
  66. ;***********************************
  67. ;* play routine
  68. ;*
  69. ;* r1=list of play buffers
  70.  
  71. ;****    sampling rate conversion
  72.     move    y:(r1),r4        ;r4=output buf
  73.     move    r4,r7            ;r7=copy of r4
  74.     move    #rateconv,r3        ;r3=rateconv structure
  75.     move    x:bufptr,r6        ;r6=old bufptr
  76.  
  77.     movec    #DELFINA_SAMPLES*2-1,m2 ;m2=input buffer mask
  78.     jsr    <delf_playrate        ;rate conversion
  79.  
  80.  
  81. ;****    duplicate left channel for mono output
  82.     movec    m0,m7            ;#$ffff
  83.     move    y:mono,b
  84.     tst    b    r7,r0
  85.     jeq    not_mono
  86.     move    r7,n7
  87.     move    x:(r0)+,a
  88.     rep    #127
  89.     move    x:(r0)+,a    a,y:(r7)+
  90.     move    a,y:(r7)
  91.     move    n7,r7
  92. not_mono
  93.  
  94.  
  95. ;****    volume adjustment
  96.     move    y:volume,x1
  97.     move    #<$40,a            ;0.5 = 100%
  98.     cmp    x1,a    r7,r0
  99.     jeq    no_volume
  100.  
  101.     ori    #$08,mr                    ;SCALE UP mode
  102.     movec    m0,m5            ;#$ffff
  103.     move    r7,r5
  104.     move    r7,r1
  105.  
  106.     move            x:(r0)+,x0    y:(r5)+,y0
  107.     mpyr    x0,x1,a        x:(r0)+,x0
  108.     mpyr    y0,x1,b        a,x:(r1)+    y:(r5)+,y0
  109.     do    #127,volume_loop
  110.     mpyr    x0,x1,a        x:(r0)+,x0    b,y:(r7)+
  111.     mpyr    y0,x1,b        a,x:(r1)+    y:(r5)+,y0
  112. volume_loop
  113.     move                    b,y:(r7)+
  114.  
  115.     andi    #$f3,mr                    ;NO SCALING mode
  116. no_volume
  117.     
  118.  
  119. ;****    double buffering
  120.     move    r6,y1            ;y1=old pointer
  121.     move    y:buf2,b        ;b= start of buf2
  122.     cmp    y1,b    r2,y0        ;y0=new pointer
  123.     jle    dbuf_buf2
  124.     cmp    y0,b    y:buf1,x0
  125.     jgt    dbuf_skip
  126. dbuf_int
  127.     move    x0,y:amybuf        ;tell amiga the new buffer
  128.     move    #int_key,a0
  129.     move    #causeqw,r0
  130.     jmp    <delf_causeq        ;interrupt and exit
  131. dbuf_buf2
  132.     cmp    y0,b    b,x0
  133.     jgt    dbuf_int
  134. dbuf_skip
  135.     rts
  136.  
  137.  
  138.  
  139. ;***********************************
  140. ;* init stuff
  141. ;*
  142. ;* x1=mono
  143. ;* x0=volume
  144. ;* y1=freq
  145. ;* y0=decoder address
  146. init
  147.     move    x1,y:mono
  148.     move    x0,y:volume
  149.     move    y1,x:freq
  150.     move    y0,y:decoder_address
  151.     rts
  152.  
  153.  
  154. ;***********************************
  155. ;* clear current buffer (pause mode)
  156. ;*
  157. ;* x1=/
  158. ;* x0=/
  159. ;* y1=/
  160. ;* y0=/
  161. mute
  162.     clr    a    y:amybuf,r0
  163.     do    #DELFINA_SAMPLES,mute_loop
  164.     move    a,l:(r0)+
  165. mute_loop
  166.     move    a,x0
  167.     rts
  168.  
  169.  
  170. ;***********************************
  171. ;* decode_and_interrupt (write output to file)
  172. ;*
  173. ;* x1=/
  174. ;* x0=/
  175. ;* y1=/
  176. ;* y0=/
  177. decode_and_interrupt
  178.     move    y:decoder_address,r0
  179.     nop
  180.     jsr    (r0)
  181. interrupt_only
  182.     move    #int_key,a0
  183.     move    #causeqw,r0
  184.     jsr    <delf_causeq
  185.     move    #<0,x0
  186.     rts
  187.  
  188.  
  189.  
  190.  
  191.     org    l:
  192.     align    4096        ;must be >= DELFINA_SAMPLES*2
  193. buf    ds    DELFINA_SAMPLES*2
  194.  
  195.  
  196.     org    x:
  197. causeqw    dc    0,0
  198. rateconv
  199. freq    dc    0
  200. bufptr    dc    buf+DELFINA_SAMPLES-50
  201.     ds    4
  202.     
  203.     org    y:
  204. ;->ydata
  205. amybuf    dc    buf
  206.  
  207. mono    dc    0
  208. volume    dc    0.5
  209. decoder_address        dc    0
  210.  
  211. buf1    dc    buf
  212. buf2    dc    buf+DELFINA_SAMPLES
  213.